refactor(repo): move typedoc reflection work into custom-theme, reduce extract-methods to a marker slicer#9073
refactor(repo): move typedoc reflection work into custom-theme, reduce extract-methods to a marker slicer#9073alexisintech wants to merge 11 commits into
Conversation
…e extract-methods to a marker slicer Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 068c809 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Repository UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
… sub-docs Extend custom-theme.mjs so every reference-object and backend-api parent page carries all method info in a canonical `## `name()`` / `## `name`` H2 shape: - renderAggregatorMethodSection synthesizes sections for callable members typedoc doesn't emit naturally (function-typed interface properties, extraMethodInterfaces, @extractMethods namespace callables emitted with qualified names). - insertSignatureBlocksIntoNaturalMethodSections injects a ```typescript block after each backend-class method's description so natural and synthesized sections share one shape. - removeMethodH2Section strips typedoc's per-overload `### Call Signature` sub-headings and lets the aggregator re-emit a single section for the primary signature. - renderAggregatorPropertyTableSection emits `## `name`` H2s for @extractMethods namespaces (listing non-callable members) and their non-callable object-shape members (expanding the object shape). Reduce extract-methods.mjs to a pure text-slicer over those sections. Zero reflection access downstream. findMethodH2Sections detects both `## `name()`` and `## `name`` shapes; reshape helpers demote to H3 and reflow into the per-method / per-property-table sub-doc shape (byte-identical to what the previous marker-block builders produced). Delete the marker-block emission entirely: renderInlineMethodsBlock, buildMethodMdx, extractCallableMembersFromDeclaration, processExtractMethodsNamespace, buildPropertyTableDocMdx, buildExtractMethodsNamespacePropertyTableMdx, and orphaned appendSignatureOnlyReturns removed from custom-theme.mjs; parseMethodMarkers, stripMethodsBlock, and both marker-block fallback paths removed from extract-methods.mjs. The `<!-- clerk:properties-start/end -->` markers stay — properties.mdx extraction still uses them post-prettier for column alignment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ctural guards
Audit-driven cleanups of `.typedoc/custom-theme.mjs` (3622 → 3464 lines). Every
edit was regenerated and `diff -rq`-verified against the pre-refactor baseline —
byte-identical output.
- Extract `wrapInlineTypeAsCode()`. Replaces the strip-backticks / strip-code-tags /
conditional single-wrap block that was copy-pasted across `declarationType`,
`unionType`, `functionType`, `arrayType`, and `reflectionType`. `functionType`'s
split-map-join around the delimiter was decorative — global `String.replace`
produces identical output on the whole string.
- Delete duplicate-typedoc structural guards. `isIntersectionTypeDoc` /
`isReferenceTypeDoc` / `isReflectionTypeDoc` / `isUnionTypeDoc` /
`coerceUnionTypeIfNeeded` existed to work around `instanceof` failing when
multiple TypeDoc copies were loaded into the tree. `find node_modules -name
typedoc` confirms a single copy under the current pnpm layout, so plain
`instanceof` works reliably. Simplifies `someType`, `declaration`,
`collectPropertyReflectionsFromIntersectionArm`, and
`isArrayElementReferenceInliningToUnion`.
- Simplify OAuth-strategy collapse helpers. Drop the `typeof
project.getReflectionsByKind === 'function'` runtime guard (stable in TypeDoc
0.28) and the useless `findNamedTypeDeclaration` fallback in
`findOAuthStrategyDeclaration` (both real `OAuthStrategy` declarations —
`packages/shared` and `packages/backend` — are TypeAliases). Inline the
`sourcePath` local. Convert `flattenUnionTypeMembersForOAuthCollapse` to
`instanceof UnionType`. The collapse itself stays — TypeScript flattens
`` `oauth_${OAuthProvider}` `` eagerly, so there is no `ReferenceType` for the
theme to preserve.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ents Bulk of the ~45 `pattern`/`replace` entries in `getCatchAllReplacements()` were the same shape: bare identifier not already inside a link/code/anchor → `[Name](/docs/…)`. Move those into a `CATCH_ALL_TYPE_LINKS` data table of `[name, url]` (or `[name, url, linkText]` when the display name differs from the match, as with `LoadedClerk` → `Clerk`), derive the regex from the name via a small `catchAllBareSymbolRegex` helper, and keep the five genuine one-offs inline (`SessionResource[]` array-suffix regex, `Appearance<Theme>`, `(CreateOrganizationParams)` in-page anchor, `**Deprecated**` full-stop, and the `**Default**` / `**Example**` / `**Examples**` prose rewrites). Also splits the previous `(SignIn|SignUp)Errors` regex into two data-table entries so every link rule is a simple identifier + url pair — makes adds trivial. `custom-plugin.mjs`: 692 → 572 lines. Byte-identical output vs baseline. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…er tag
Types that clerk-docs embeds via `<Typedoc />` inside hand-written pages need
typedoc-plugin-markdown's `## Properties` group heading suppressed so the
embedded fragment doesn't collide with the parent page's heading hierarchy.
Previously this was a hardcoded array of 33 filenames + a post-hoc regex strip
in `custom-plugin.mjs` — long-standing TODO to move the trigger to the source
declaration.
- New `@noHeading` modifier tag registered in `typedoc.config.mjs` (both
`modifierTags` and `notRenderedTags`; also added to the theme's hidden-tag
set in the `comment` partial so it doesn't render as a `**No Heading**`
badge — typedoc-plugin-markdown ignores `notRenderedTags` for modifier tags).
- `custom-theme.mjs` `MarkdownPageEvent.END` listener strips the first heading
(any level H1-H6) via `output.contents.replace(/^#{1,6} .+\n+/m, '')` when
`decl.comment.hasModifier('@noHeading')`.
- Added `/** @noHeading */` to the 31 source declarations that emit today's
live entries (verified by empty-array-then-diff experiment; 3 filenames in
the original list were dead — no typedoc-emitted file matched them). Also
added `@noHeading` to `PaginatedHookConfig` because typedoc's comment
inheritance for `interface HookParams extends PaginatedHookConfig<…>`
replaces `HookParams`'s modifier tags with the parent's — tagging the
parent gets it inherited (parent is `@inline` so it has no page of its own).
- Deleted `FILES_WITHOUT_HEADINGS` and its strip from `custom-plugin.mjs`.
`custom-plugin.mjs`: 573 → 514 lines. Byte-identical output vs baseline.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The `accessor` partial in `ClerkMarkdownThemeContext` is never invoked.
typedoc-plugin-markdown would dispatch to `partials.accessor` from its default
`member` partial for accessor-kind reflections, but the theme's custom `member`
partial returns `''` for accessors and short-circuits that path — accessor
rendering happens in `memberWithGroups` (as a compact "Property" table)
instead. The header comment already hedged this ("Fallback single-row
rendering if used directly elsewhere"); nothing does.
Verified byte-identical output vs baseline.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The `swap()` function was a three-line array-index swap used exactly once by the `signature` partial to reorder the `@displayFunctionSignature` output. Inline as destructuring so the transformation is legible without a jump-away. Verified byte-identical output vs baseline. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`grep -rln "@paramExtension" packages/*/src` returns zero hits — the tag is never used on any source declaration. The custom handler in the `signature` partial (which would insert extra content after the Parameters section) was therefore unreachable. Removes the handler branch plus the tag registration in `CUSTOM_BLOCK_TAGS`. The `@displayFunctionSignature` swap logic that shared the same split/join scaffolding is simplified to a direct return path. Verified byte-identical output vs baseline. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…uplicating `escapeChars` was defined twice — once in `.typedoc/markdown-helpers.mjs` (exported) and once as a local function in `.typedoc/custom-theme.mjs`, with byte-identical bodies. Import the shared version and delete the local copy. Verified byte-identical output vs baseline. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3715853 to
068c809
Compare
Description
Unifies the
.typedoc/pipeline so every reference-object and backend-api parent page carries all the info its extracted sub-docs need in a canonical##H2 shape, andextract-methods.mjsbecomes a pure text-slicer over those H2s — no reflection access, no marker block. Same generated docs.Before:
extract-methods.mjswas a second reflection walker layered on top of the markdown theme. It re-imported TypeDoc AST types, re-derived method/property partitioning, and re-invokedMarkdownThemeContextpartials to build each per-method MDX file. Two places in the codebase had to agree on how methods vs properties are partitioned, which acronyms slug how, and which comment tags trigger inline extraction.After: all reflection work lives in
custom-theme.mjs, which now synthesizes:## `name()`H2 sections for every callable member that typedoc-plugin-markdown doesn't emit naturally (function-typed interface properties,
extraMethodInterfaces,@extractMethodsnamespace callables likeemailCode.sendCode). Backend-class methods get a```typescriptsignature block injected after their natural description so all H2s share one shape.## `name`H2 sections for
@extractMethodsnamespaces with non-callable object-shape members (emailLinkonSignInFutureResource) and each such non-callable member (emailLink.verification) — the same rows the marker-block builders used to write directly to sub-docs.Overloaded backend-class methods: strip typedoc's per-overload
### Call Signaturesub-headings and re-emit a single section for the primary signature, so the parent's shape is uniform across single- and multi-overload methods.extract-methods.mjsslices those H2s pre-prettier, reshapes each intomethods/<slug>.mdx(H2 → H3, then straight verbatim), and defers Properties extraction to apreWriteAsyncJobthat reads the (now prettier-aligned)<!-- clerk:properties-start/end -->markers and writesproperties.mdx.Commits
refactor(repo): move typedoc reflection work into custom-theme, reduce extract-methods to a marker slicer— the first move: reflection walks live in one place,extract-methodsreads marker-wrapped output produced by the theme. Byte-identical to the pre-refactor docs.refactor(repo): text-slice parent H2 aggregator sections into methods sub-docs— the follow-through: parent pages carry the info directly (methods + property tables),extract-methodsbecomes a pure text-slicer, and the marker-block emission is deleted entirely. Byte-identical for every sub-doc; the only expected output delta is the parent pages themselves, which now show their##name()/ `## `nameH2 sections in full.refactor(repo): consolidate custom-theme code-wrap and drop dead structural guards— audit follow-up oncustom-theme.mjs: extract onewrapInlineTypeAsCodehelper across the 5 partials that used to open-code the strip-backticks / single-wrap dance; delete the four structural type-check helpers pluscoerceUnionTypeIfNeededafter confirming a singletypedoccopy under pnpm makesinstanceofreliable; simplify the OAuth-strategy collapse helpers. 3622 → 3464 lines. Byte-identical output.refactor(repo): data-drive custom-plugin catch-all type-link replacements— the ~45pattern/replaceentries ingetCatchAllReplacements()collapse into aCATCH_ALL_TYPE_LINKSdata table of[name, url](plus a third field for the rare cases where the display name differs from the match, e.g.LoadedClerk→Clerk), with the regex derived fromname. Five genuine one-offs stay inline (SessionResource[]array-suffix regex,Appearance<Theme>,(CreateOrganizationParams)in-page anchor,**Deprecated**full-stop, and the**Default**/**Example**/**Examples**prose rewrites). Adding a new type link is now one row. 692 → 572 lines. Byte-identical output.refactor(repo): replace FILES_WITHOUT_HEADINGS with @noHeading modifier tag— the long-standing TODO on.typedoc/custom-plugin.mjs's 33-filename allowlist finally lands. Types embedded via<Typedoc />inside hand-written docs now opt into heading suppression at the source with/** @noHeading */; the theme'sMarkdownPageEvent.ENDlistener strips the first heading (any level H1-H6) viaoutput.contents.replace(/^#{1,6} .+\n+/m, '')when the reflection carries the modifier. 31 declarations tagged (verified by empty-array-then-diff experiment — 3 filenames in the original list were dead). Also taggedPaginatedHookConfigbecause typedoc's comment inheritance forinterface HookParams extends PaginatedHookConfig<…>clobbers the child's modifier tags with the parent's — the parent is@inlineso it doesn't emit its own page. Byte-identical output.refactor(repo): remove dead accessor partial from custom-theme— theaccessorpartial inClerkMarkdownThemeContextwas never invoked: typedoc-plugin-markdown would dispatch to it from its defaultmemberpartial for accessor-kind reflections, but the theme's custommemberreturns''for accessors and short-circuits that path (accessors render as a compact "Property" table inmemberWithGroupsinstead). −11 lines, byte-identical output.refactor(repo): inline swap() helper into signature partial— three-line array-index swap used exactly once by thesignaturepartial to reorder@displayFunctionSignatureoutput. Inlined as destructuring so the transformation is legible without a jump-away. −15 lines net, byte-identical output.refactor(repo): remove dead @paramExtension handler and tag registration—grep -rln "@paramExtension" packages/*/srcreturned zero hits; the tag was registered inCUSTOM_BLOCK_TAGSbut never used on any source declaration, making the ~25-line handler branch in thesignaturepartial unreachable. Removed the handler, dropped the tag fromCUSTOM_BLOCK_TAGS, and simplified the sibling@displayFunctionSignaturepath that shared the same split/join scaffolding. −32 lines net, byte-identical output.refactor(repo): import escapeChars from markdown-helpers instead of duplicating—escapeCharswas defined twice with byte-identical bodies (once exported from.typedoc/markdown-helpers.mjs, once as a local in.typedoc/custom-theme.mjs). Import the shared version. −17 lines net, byte-identical output.Refs
Checklist
pnpm testruns as expected. (.typedocvitest: 16/16 pass)pnpm buildruns as expected.Type of change